
Version:=1.5
ModuleName:=sysklogd

Object:=$(ModuleName).tgz
ObjectDir:=$(ModuleName)-$(Version)
ObjectSource:=$(ModuleName)-$(Version).tar.gz

Version2:=3.7.1
ModuleName2:=logrotate

Object2:=$(ModuleName2).tgz
ObjectDir2:=$(ModuleName2)-$(Version2)
ObjectSource2:=$(ModuleName2)_$(Version2).orig.tar.gz

DependFiles:=
InstaEtcDir:=usr/local/etc
InstaLibDir:=usr/lib
InstaSbinDir:=usr/local/sbin
StatusFileDir:=var/lib/

InstallDirTmp:=usr/local/$(ModuleName)
InstallDir:=/$(InstallDirTmp)
ManDir:=/tmp

PatchName:=sysklogd-1.5.patch
PATCH:=patch -p0 < $(PatchName)
PATCH2:=
Config:=

.PHONY: all patch clean dist_clean

all:$(Object) 

$(Object):$(ObjectSource) syslog.conf $(ObjectSource2) logrotate.conf
	tar -xzf $(ObjectSource)
	$(PATCH)
	$(MAKE) -C $(ObjectDir)
	mkdir -p $(InstaEtcDir) $(InstaSbinDir) $(InstaLibDir) $(StatusFileDir)
	cp $(ObjectDir)/syslogd $(InstaSbinDir)
	cp syslog.conf $(InstaEtcDir)
	tar -xzf $(ObjectSource2)
	$(PATCH2)
	$(MAKE) -C $(ObjectDir2)
	cp $(ObjectDir2)/logrotate $(InstaSbinDir)
	cp logrotate.conf $(InstaEtcDir)
	cp -af /lib/libpopt.so* $(InstaLibDir)
	rm -rf var/lib && ln -sf /usr/lib var/lib
	tar -czf $(Object) usr var

# The rule will error and I don't see why :(
patch:
	$(MAKE) -C $(ObjectDir) clean
	mv $(ObjectDir) $(ObjectDir).new
	tar -xzf $(ObjectSource)
	diff -ur $(ObjectDir) $(ObjectDir).new > $(PatchName);\
		echo $? # The return code of diff is 1,so make think have error:(

clean:
	rm -rf $(Object) usr $(Object2) var

dist_clean:clean
	rm -rf $(ObjectDir) $(ObjectSource) tmp $(ObjectDir).new $(Object2) $(ObjectSource2) $(ObjectDir2) var
	
include ../Makefile.Res
